{% extends "admin/base.html" %}

{% block content %}
<div class="container">
  <div class="row" style="margin: 1em 0 1em 0;">
    <div class="span12">
      <form class="form-horizontal" action="." method="GET">
        <div class="control-group">
          <label class="radio inline">
          User name (
          </label>
          <label class="radio inline">
            <input type="radio" name="unamesearch" value="is" {% if args.unamesearch == 'is' %}checked{% endif %} /> is &nbsp; | 
          </label>
          <label class="radio inline">
            <input type="radio" name="unamesearch" value="contains" {% if args.unamesearch != 'is' %}checked{% endif %} /> contains &nbsp;) :
          </label>
          <input type="text" name="uname" value="{{ args.uname }}"/>
        </div>
        <div class="control-group">
          User ID is:
          <input type="text" name="uid" value="{{ args.uid }}"/>
        </div>
        <div class="control-group">
          <label class="radio inline">
            <input type="radio" name="migrated" value="migrated" {% if args.get('migrated') == 'migrated' %}checked{% endif %} /> Migrated
          </label>
          <label class="radio inline">
            <input type="radio" name="migrated"  value="unmigrated" {% if args.get('migrated') == 'unmigrated' %}checked{% endif %} /> Unmigrated
          </label>
          <label class="radio inline">
            <input type="radio" name="migrated"  value="all" {% if args.get('migrated') != 'migrated' and args.get('migrated') != 'unmigrated' %}checked{% endif %}/> All
          </label>
        </div>
        <input type="submit" class="btn" value="Search"/>
      </form>
    </div>
  </div>
  <div>
    {% if pages %}
    <h3>Page {{ page }} of {{ pages }}</h3>
    <div class="pagination pagination-mini">
      <ul>
      {% for p in range(0,pages) %}
        {% if p+1 == page %}
          <li class="active"><a href="#">{{ p+1 }}</a></li>
        {% else %}
          <li><a href="{{ request.path }}?{{ querystring }}&page={{ p+1 }}">{{ p+1 }}</a></li>
        {% endif %}
      {% endfor %}
      <ul>
    </div>
    {% endif %}
  </div>
  {% for user in users %}
    <div>
    <h3>{{ user.uname }}
    <span class="badge badge-{% if user.migrated %}success{% else %}important{% endif %}">{% if not user.migrated %}un{% endif %}migrated</span>
    </h3>
    <strong>UID:</strong> {{ user.uid }}<br/>
    <h4>Files</h4>
    <ul>
    {% for file in user.files %}
      <li><a href="{{ storage_root }}{{ file }}">{{ file }}</a></li>
    {% endfor %}
    </ul>
    <h4>StoryMaps</h4>
    {% for storymap in user.storymaps.values() %}
      <div>
        <h5>{{ storymap.title }}</h5>
        <strong>ID:</strong> {{ storymap.id }} <br/> 
        <strong>Draft:</strong> {{ storymap.draft_on }} <br/>
        <strong>Published:</strong> {{ storymap.published_on }} <br/>
      </div>
    {% endfor %}
    </div>
  {% endfor %}
</div>
{% endblock content %}
